<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>destructuring</title>
</head>
<body>
<script>
    /*
        指定默认值
    */
    // demo1
    /*let [a='1']=[];
    console.log(a) /!*1*!/*/

    // demo2
    /*let [a='1']=[2];
    console.log(a) /!*2*!/*/

    // demo3
    /*let [a='1',b]=[2];
    console.log(a) /!*2*!/
    console.log(b) /!*undefind*!/*/

    // demo4
    let [xa=a,b=1]=[2];
    console.log(xa) /*2*/
    console.log(b) /*1*/

    // demo5
    /*let [a,b=1]=[1,undefined];
    console.log(a) /!*1*!/
    console.log(b) /!*1*!/*/

    // demo6 error 数组 = 非遍历解构
   /* let [a]=1;
    let [a]=false;
    let [a]=NaN;
    let [a]=undefined;
    let [a]=null;
    console.log(a) /!*error*!/*/
</script>
</body>
</html>